/**
 * Copyright © 2009 Qasky. All rights reserved.
 *
 * 整个项目通用状态管理
 *
 * @author Wang Hongya
 * @version 0.0.0 2019/11/20
 *
 * History:
 * (author, date, desc)
 * (Wang Hongya, 20191120, 添加注释)
 */
import {loadSysDictsBySort} from "api/sysDictApi";
import {loadAlgorithmBySort} from 'api/arithmeticDict'

const common = {
    state: {
        formStyle: {
            labelCol: {span: 6},
            wrapperCol: {span: 17}
        },
        formStyleUnit: {
            labelCol: {span: 8},
            wrapperCol: {span: 15}
        },
        formItemLayoutWithOutLabel: {
            wrapperCol: {span: 20, offset: 6}
        },
        formItemLayoutWithOutLabelT: {
            wrapperCol: {span: 20, offset: 8}
        },
        hostStatusType: [{codeValue: "processing", code: '01'},{codeValue: "error", code: '02'}],//主机状态
        hostStatusList: [{label: "异常", value: 0},{label: "正常", value:1}],//主机状态
        phyMachineStatusList:[],//物理机的状态
        deviceTypeList:[],//物理机的类型
        roleTypeList:[],//物理机的类型
        maxLength:0,
        statusList:[{label: "正常", value: "1"},{label: "异常", value: "2"}],
        qsBackData:{}
    },
    mutations: {
        setSysDictsBySortValue ( state, obj) {
            let type = obj.type
            state[type] = obj.cotData
        },
        
        setSysDictsByCodeTypeValue ( state, obj) {
            let type = obj.type
            if(obj.cotData.code === 0){
                state[type] = obj.cotData.data
                console.log(state[type])
            }else{
                state[type] = []
            }
        },
        getGlobalBackData (state, arg) {
            state.qsBackData = arg
        },
    },
    actions: {
        loadSysDictsAct ( context,prams) {
            let sortCode = prams.code
            let list = prams.list
            return loadSysDictsBySort ({sortCode}).then (response => {
                let data = response.data
                context.commit ('setSysDictsBySortValue', {cotData:data,type:list})
            })
        },
        setGlobalBackData ({commit}, arg) {
            commit('getGlobalBackData', arg)
        },
    }
}

export default common
